/**
 * Created by fangcailiang on 16/6/16.
 */

function add1(n){
    var sum = 0;
    for(var i=1; i<=n; i ++){
        sum += i;
    }
    return sum;
}

console.log(add1(100));


function add2(n){
    if(n == 1){
        return 1;
    }else{
        return add2(n -1) + n;
    }
}

console.log(add2(100));


function add3(n){
    return (1 + n) * n/2;
}

console.log(add3(100));